package com.niiwoo.civet.trade.configuration;

import com.niiwoo.civet.trade.constant.RabbitConstant;
import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 考拉理财MQ配置
 *
 * @author liming
 * @date 2017-12-29 14:21
 */
@Configuration
public class KaoLaLiCaiMqConfiguration {

    //**********************
    //考拉理财债权转让(借款人还款逾期时)合同签署
    //**********************
    @Bean
    public Exchange kaoLaExchange() {
        return new DirectExchange(RabbitConstant.Exchange.KAOLA_EXCHANGE, true, true);
    }

    @Bean
    public Queue kaolaCreditAssignmentQueue() {
        return new Queue(RabbitConstant.Queue.KAOLA_CREDIT_ASSIGNMENT, true);
    }

    @Bean
    public Binding kaolaCreditAssignmentContractBinding() {
        return BindingBuilder.bind(kaolaCreditAssignmentQueue())
                .to(kaoLaExchange())
                .with(RabbitConstant.RoutingKey.KAOLA_CREDIT_ASSIGNMENT_CONTRACT).noargs();
    }
}
